import xlrd
import pyecharts.options as opts
data=xlrd.open_workbook(r'C:\Users\chumenliuxiang\Desktop\实验室作业\作业.xls','r')
sheet_num=data.nsheets
# print(sheet_num)
biao1=data.sheet_by_name('Sheet1')
# print(biao1)
yuce=biao1.col_values(0)
shiji=biao1.col_values(1)
e=biao1.col_values(2)
yuce=yuce[1:]
shiji=shiji[1:]
e=e[1:]
# print(e)
# print(shiji)
jun=0
for i in shiji:
    jun=jun+i
jun=jun/21
# print(jun)
ssr=0
for i in yuce:
    ssr=(i-jun)**2+ssr
# print(ssr)
sst=0
for j in shiji:
    sst=(j-jun)**2+sst
# print(sst)
res=0
for i in e:
    res+=i**2
r2=1-res/sst
print(r2)
